package com.bittech.wiki_learn.controller;

import com.bittech.wiki_learn.req.EbookReq;
import com.bittech.wiki_learn.resp.CommonResp;
import com.bittech.wiki_learn.resp.EbookResp;
import com.bittech.wiki_learn.service.EbookService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/ebook")
/**
 * 在Controller层不能直接出现Domain层类，需要将入参与返回值封装，
 * 不暴露表中敏感信息
 */
public class EbookController {
    @Resource
    private EbookService eBookService;

    @RequestMapping(value = "/selectBookByName",method = RequestMethod.GET)
    public CommonResp<List<EbookResp>> selectBookByName(EbookReq ebookReq) {
        List<EbookResp> resp =
                eBookService.queryBookByName(ebookReq);
        // 封装resp
        CommonResp<List<EbookResp>> commonResp =
                new CommonResp<>();
        commonResp.setContent(resp);
        commonResp.setMessage("查询成功!");
        return commonResp;
    }
}
